import React, { Component } from 'react'
import BScroll from 'better-scroll'

export class MyScroll extends Component {
    componentDidMount() {
        const { direction } = this.props
        this.timer = setTimeout(() => {
            this.bs = new BScroll(`.${direction}`, {
                scrollX: direction === 'heng',
                scrollY: direction === 'shu'
            })
        }, 200)
    }
    render() {
        const { direction } = this.props
        return (
            <div className={direction}>
                {this.props.children}
            </div>
        )
    }
}

export default MyScroll